package 
{
	import flash.display.*;
	import flash.events.*;
	import iks.utils.geom.*;
	import vehicle.*;
	
	public class Main extends Sprite 
	{
		
		public function Main():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
			
			this.stage.frameRate = 30;
			
			m_vehicle1 = new SteeredVehicle();
			m_vehicle1.edgeBehavior = Vechicle.BOUNCE;
			m_vehicle1.position = new Vector2D(200, 200);
			this.addChild(m_vehicle1);
			
			m_vehicle2 = new SteeredVehicle();
			m_vehicle2.edgeBehavior = Vechicle.BOUNCE;
			m_vehicle2.position = new Vector2D(400, 200);
			this.addChild(m_vehicle2);
			
			m_vehicle3 = new SteeredVehicle();
			m_vehicle3.edgeBehavior = Vechicle.BOUNCE;
			m_vehicle3.position = new Vector2D(300, 260);
			this.addChild(m_vehicle3);
			
			this.addEventListener(Event.ENTER_FRAME, onEnterFrameHandler);
		}
		
		private function onEnterFrameHandler(evt : Event) : void
		{
			m_vehicle1.seek(m_vehicle2.position.clone());
			m_vehicle1.flee(m_vehicle3.position.clone());
			
			m_vehicle2.seek(m_vehicle3.position.clone());
			m_vehicle2.flee(m_vehicle1.position.clone());
			
			m_vehicle3.seek(m_vehicle1.position.clone());
			m_vehicle3.flee(m_vehicle2.position.clone());
			
			m_vehicle1.update();
			m_vehicle2.update();
			m_vehicle3.update();
			
			//m_vehicle1.seek(new Vector2D(this.mouseX, this.mouseY));
			//m_vehicle1.update();
		}
		
		private var m_vehicle1 : SteeredVehicle = null;
		private var m_vehicle2 : SteeredVehicle = null;
		private var m_vehicle3 : SteeredVehicle = null;
	}
	
}

































///////////////////////////////////////////////////////////////////////////////////////////////////
// end file


